var user = require('./user');
var points = require('./points');
var payment = require('./payment');
var share = require('./web/share');
var product = require('./api/product');
var comment = require('./api/comment');
var order = require('./api/order');
var orderReturn = require('./api/orderReturn');
var shoppingItem = require('./api/shoppingItem');
var address = require('./api/address');
var SGMe = require('./api/sguser');
var groupBuy = require('./api/groupBuy');
var login = require('./api/login');
var kdWD = require('./api/kdproduct');

module.exports = function(app){
    //对吧的接口回调
    app.get('/points/autoLogin/:uid',points.autoLogin);
    app.get('/points/cost',points.cost);
    app.get('/points/confirm',points.confirm);
    //用户相关路由
    app.get('/user',user.list);
    //红包分享相关
    app.get("/share/:shareType",share.handler);
    //支付相关
    app.post('/payment',payment.createPay);
    //红包分享相关
    app.get("/share/:shareType",share.handler);
    app.post("/coupons", share.postCoupon);
    app.get('/coupons/:couponId', share.getCouponTemplate);
    app.get('/coupons', share.getCoupons);
    //海外购相关
    // 商品相关
    app.get('/banners', product.getBanner);
    app.get('/productTypes', product.getProductType); //localhost:3000/productTypes
    app.get('/newProducts', product.getNewProducts); //localhost:3000/newProducts
    app.get('/searchProducts', product.getSearchProduct); //localhost:3000/searchProducts?keyword=SW
    app.get('/products', product.getProducts); //localhost:3000/products?productTypeId=mUvfwqg2j8&page=1
    app.get('/products/:productId', product.getProduct); //http://localhost:3000/products/4u2iGZd3fj
    // 商品评论
    app.get('/products/:productId/comments', comment.getComments); //http://localhost:3000/products/4u2iGZd3fj/comments
    app.post('/products/:productId/comments', comment.postComment);

    // 订单相关
    app.get('/orders', order.getOrders); //http://localhost:3000/orders?userId=yU0hhBFLob&status=3
    app.get('/kdOrders', order.getkdOrders);
    app.post('/orders', order.postOrder); // localhost:3000/orders
    app.get('/kdOrders/:id', order.getkdOrder); //http://localhost:3000/orders/LaIfEFg9s6
    app.get('/orders/:orderId', order.getOrder);
    app.post('/orders/:orderId', order.editOrder);
    app.delete('/orders/:orderId', order.deleteOrder);
    app.put('/orderExpress/:orderId', order.setExpressInfo);
    app.put('/setPayInfo/:orderId', order.setPayInfo, groupBuy.postGroupOrder, groupBuy.joinGroupBuy);
    app.get('/orderProducts', order.getOrderProducts);
    app.get('/categoryCount', order.categoryOrderCount);
    app.get('/orderStatus', order.getOrderStatus);

    // 退单相关
    app.get('/orderReturns', orderReturn.getOrderReturns);// http://localhost:3000/orderReturns?userId=gj29R3Fc5a
    app.post('/orderReturns', orderReturn.postOrderReturn); //http://localhost:3000/orderReturns
    app.get('/orderReturns/:orderReturnId', orderReturn.getOrderReturn); //http://localhost:3000/orderReturns/xaRQDxWG1E
    app.put('/orderReturns/:orderReturnId', orderReturn.editOrderReturn); //http://localhost:3000/orderReturns/xaRQDxWG1E
    app.delete('/orderReturns/:orderReturnId', orderReturn.deleteOrderReturn); //http://localhost:3000/orderReturns/xaRQDxWG1E
    app.post('/orderReturnProgress/:orderReturnId', orderReturn.setOrderReturnProgress);
    // 购物车接口
    app.get('/shoppingItems', shoppingItem.getShoppingItem);
    app.post('/shoppingItems', shoppingItem.postShoppingItem);
    app.put('/shoppingItems/:shoppingItemId', shoppingItem.putShoppingItem);
    app.delete('/shoppingItems/:shoppingItemId', shoppingItem.deleteShoppingItem);
    app.get('/shoppingItemCount', shoppingItem.getShoppingItemCount);

    //  地址相关接口
    app.get('/address', address.getAddress);// localhost:3000/address?userId=G5BBwDXQVs
    app.get('/address/:addressId',address.getAddressInfo);
    app.post('/address', address.postAddress);
    app.put('/address/:addressId', address.editAddress);
    app.delete('/address/:addressId', address.deleteAddress);
    app.get('/defaultAddress', address.getDefaultAddress);
    app.put('/defaultAddress',address.setDefaultAddress);
    //用户界面我的
    app.get('/sgUser/:userId',SGMe.getMe);
    //查询优惠码是否有效
    app.post('/checkSaleCode', order.checkSaleCode);
    //用户反馈
    app.post('/feedBack', order.postFeedBack);
    //团购相关接口
    app.get('/groupProducts', groupBuy.getGroupProducts);
    app.get('/groupProducts/:id', groupBuy.getGroupProduct);
    app.get('/groupOrders/:id', groupBuy.getGroupOrder);
    app.get('/recommendProduct', groupBuy.getRecommendProducts);
    app.post('/checkGroup', groupBuy.checkGroupStatus);
    app.get('/mainPageGroupProducts', groupBuy.MainPageProducts);
    //优惠券接口
    app.get('/seagouCoupon', product.getCoupons);
    app.post('/seagouCoupon', product.postCoupon); //领取优惠券
    app.get('/myCoupons', product.getMyCoupons);
    app.get('/seagouCoupons/:couponId', product.getCoupon);
    app.post('/suitCoupon', product.getOptimalCoupon);
    //登录接口
    app.get('/wxLogin',login.wxLogin);
    app.get('/redirectWX',login.redirectWX);
    // test co 测试co模块，异步转同步
    app.get('/testCo/:productId', product.getXXXXX);
    //获取指定kd微店
    app.get('/kdShop/:id', kdWD.getKDShop);
    app.get('/kdProduct/:id', kdWD.getKDProduct);
    // 提交微店订单
    app.post('/KdOrder', kdWD.createKdOrder);
    // kd微店购物车接口
    app.get('/kdShoppingItems', shoppingItem.kdGetShoppingItem);
    app.post('/kdShoppingItems', shoppingItem.kdCreateShoppingItem);
    app.put('/kdShoppingItems/:shoppingItemId', shoppingItem.kdPutShoppingItem);
    app.post('/deletekdShoppingItems', shoppingItem.kdDeleteShoppingItem);
    app.get('/kdShoppingItemCount', shoppingItem.kdGetShoppingItemCount);
    // kd微店地址管理接口
    app.post('/createkdAddress', address.createKDAddress);
    app.put('/editkdAddress/:id', address.editKDAddress);
    app.get('/kdAddress', address.getKDAddress);
    app.get('/kdGoodsSearch', kdWD.kdSearch)
};
